﻿using Application.Dto;
using Application.IAppSrevices;
using AutoMapper;
using Domain.Entitys;
using EFCore.Repositorys;
using Microsoft.AspNetCore.Mvc;

namespace UI.Controllers
{
    public class CMKController : Controller
    {
        private readonly IMapper mapper;
        private readonly ICMKService cMKService;
        private readonly ICMService cMService;

        public CMKController(IMapper mapper,ICMKService cMKService,ICMService cMService)
        {
            this.mapper = mapper;
            this.cMKService = cMKService;
            this.cMService = cMService;
        }

        public IActionResult Index()
        {
            return View();
        }
        [HttpGet]
        public IActionResult Add()
        {
            return View();
        }

        [HttpPost]
        public async Task<IActionResult> Add(CMKAddDto cMKAddDto)
        {
            int num = await cMKService.CMKAddAsync(cMKAddDto);
            return Json(num);
        }

        public async Task<IActionResult> CMKSelect(int pageIndex, int pageSize)
        {
            List<CMK> cMKs = await cMKService.CMKSelect(pageIndex, pageSize);
            return Json(cMKs);
        }
        public IActionResult CMKSelectCount()
        {
            int num = cMKService.CMKSelectCount();
            return Json(num);
        }
        public async Task<IActionResult> CMKAddAsync(CMKAddDto cMKAddDto)
        {
            int num = await cMKService.CMKAddAsync(cMKAddDto);
            return Json(num);
        }
        public async Task<int> CMKDelete(int id)
        {
            return await cMKService.CMKDeleteAsync(id);
        }


        public async Task<int> CMDelete(string id)
        {
            return await cMService.CMDeleteAsync1(id);
        }
      /*  [HttpGet]
        public async Task<IActionResult> GetCMKCM()
        {
            return Json(await cMService.GetCMKCM());
        }*/

    }
}
